﻿using System;
using Renci.iRods.Common;

namespace Renci.iRods
{
    public class ConnectionInfo
    {
        /// <summary>
        /// Gets the irods user name.
        /// </summary>
        public string Username { get; private set; }

        /// <summary>
        /// Gets the irods server host to connect to.
        /// </summary>
        public string Host { get; private set; }

        /// <summary>
        /// Gets or sets the port the server is listening on.
        /// </summary>
        /// <value>
        /// The port.
        /// </value>
        public uint Port { get; private set; }

        /// <summary>
        /// Gets or sets the authentication scheme to use.
        /// </summary>
        /// <value>
        /// The authentication scheme to use.
        /// </value>
        public AuthenticationTypes AuthenticationScheme { get; private set; }

        /// <summary>
        /// Gets or sets the default resource to use when storing.
        /// </summary>
        /// <value>
        /// The default resource to use when storing.
        /// </value>
        public string DefaultResource { get; private set; }

        /// <summary>
        /// Gets the irods Zone. The name of home irods data grid.
        /// </summary>
        public string Zone { get; private set; }

        /// <summary>
        /// Gets or sets the server's distinguished name. For GSI authentication.
        /// </summary>
        /// <value>
        /// The server's distinguished name.
        /// </value>
        public string ServerDistinguishedName { get; private set; }

        public string Password { get; private set; }

        public string Option { get; set; }

        /// <summary>
        /// Gets or sets the object packing type.
        /// </summary>
        /// <value>
        /// The object packing type.
        /// </value>
        public PackingType PackingType { get; set; }

        public string Version { get; private set; }

        public string ApiVersion { get; private set; }


        /// <summary>
        /// Initializes a new instance of the <see cref="ConnectionInfo"/> class.
        /// </summary>
        /// <param name="host">The irods server host to connect to.</param>
        /// <param name="username">The irods user name.</param>
        /// <param name="zone">The zone.</param>
        /// <param name="password">The password.</param>
        public ConnectionInfo(string host, uint port, string username, string password, string resoureName, string zoneName, AuthenticationTypes authenticationType = AuthenticationTypes.Password, string serverDistinguishedName = "", PackingType packingType = PackingType.Xml)
        {
            this.Host = host;

            this.Port = port;

            this.Username = username;

            this.Password = password;

            this.DefaultResource = resoureName;

            this.Zone = zoneName;

            this.PackingType = packingType;

            this.AuthenticationScheme = authenticationType;

            this.ServerDistinguishedName = serverDistinguishedName;

            this.Version = "rods2.4.1";

            this.ApiVersion = "d";
        }

        public ConnectionInfo(string host, string username, string password, PackingType packingType = PackingType.Xml)
            : this(host, 1247, username, password, string.Empty, string.Empty, AuthenticationTypes.Password, string.Empty, packingType)
        {
        }

        public ConnectionInfo(string host, string username, string password, string resourceName, PackingType packingType = PackingType.Xml,AuthenticationTypes authenticationType = AuthenticationTypes.Password, string serverDistinguishedName = "")
            : this(host, 1247, username, password, resourceName, string.Empty, authenticationType, serverDistinguishedName, packingType)
        {
        }

        public ConnectionInfo(string host, uint port, string username, string password, string resourceName, PackingType packingType = PackingType.Xml, AuthenticationTypes authenticationType = AuthenticationTypes.Password, string serverDistinguishedName = "")
            : this(host, port, username, password, resourceName, string.Empty, authenticationType, serverDistinguishedName, packingType)
        {
        }
    }
}
